Skip to content

Conversation

DouisLavid
Copy link
Contributor

This is the counterpart of the implementation of Float for OrderedFloat as Real is "A trait for real number types that do not necessarily have floating-point-specific characteristics such as NaN and infinity."

Operations that would result in a NaN cause a panic, as it is the behaviour that it suggested in the num_trait docs. Checks for NaN results are only done in cases where a NaN could be expected, and assumes that the implementation of Real for the underlying type is sane otherwise.

…oatCore

Forwards the calls of Real trait methods to the underlying type, panicking when the result is NaN, as suggested in https://docs.rs/num-traits/latest/num_traits/real/trait.Real.html
Also adds a few tests to ensure things actually panic when they should.
Copy link
Collaborator

@mbrubeck mbrubeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mbrubeck
Copy link
Collaborator

Looks like this code needs to require cfg(any(feature = "std", feature = "libm")).

@mbrubeck mbrubeck merged commit 1841f05 into reem:master Aug 22, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants